<template>
	<view class="contents">
		<!-- 头像 -->
		<view class="avatar" v-if="value.user">
			<!-- <image
        class="zanImg"
        src="https://cdn.uviewui.com/uview/album/1.jpg"
      ></image> -->
			<u-avatar class="zanImg" :src="value.user.avatar_url" @click="goHome"></u-avatar>
		</view>
		<view class="avatarRight">
			<!-- 昵称，时间 -->
			<view class="nickTime">
				<view class="nick" v-if="value.user && value.touser">
					{{ value.user.nick_name }}
					<view class="laoshi" v-if="value.user.is_teacher">老师</view>
					<view class="daoshi" v-if="value.user.is_senators">导师</view>
					回复
					{{ value.touser.nick_name }}
					<view class="laoshi" v-if="value.touser.is_teacher">老师</view>
					<view class="daoshi" v-if="value.touser.is_senators">导师</view>
				</view>
				<!-- <view class="time">{{value.create_time}}</view> -->
			</view>
			<!-- 内容 -->
			<view class="detail" v-if="value.grade_auth <= my_level_id">{{ value.content }}</view>
			<view class="detail_live" v-else>
				{{value.content}}
				<view class="detail_view">
					该内容仅支持{{value.grade_auth_name}}及以上行者查看 <u-icon name="arrow-right" size="24rpx"></u-icon>
				</view>
			</view>
			<view class="item_right_sound" v-if="promptSound">
				<progressBar :way="1" color="#444444"></progressBar>
			</view>
			<view class="time_reply" v-if="reply_one">
				<view class="time_reply_left">
					1小时前 <text @click="handReply">回复</text>
				</view>
				<view class="time_reply_right" :style="{
            color: value.is_like ? '#55B877' : '#888888',
          }" @click="handZan(value.is_like)">
					<image class="zanImg1" v-show="value.is_like"
						src="@/static/images/slices/icon_tlzxq_dianzan_xuanzhong.png"></image>
					<image class="zanImg1" v-show="!value.is_like" src="@/static/weichuang/icon_fld_dianzan.png">
					</image>
					<!-- 赞 -->
					{{ value.like_count ? value.like_count : "赞" }}
				</view>
				<!-- <view class="time_reply_right" v-else :style="{
						'color':value.is_like?'#55B877':'#888888'
					}" @click="handZan(1)">
					<image class="zanImg1" src="@/static/weichuang/icon_fld_dianzan.png"></image>
					赞
				</view> -->
			</view>
		</view>
	</view>
</template>
<script>
	import progressBar from "@/pages/components/progress_bar.vue"; //录音
	// import {
	// 	likeDiscuss,
	// 	huifuChildren
	// } from '@/common/api/start.js'

	// import {
	// 	pinglunChildren,
	// 	dianzan,
	// } from '@/common/api/jiazu.js'
	import {
		pinglunChildren,
		dianzan
	} from "@/common/api/gongchuang.js";
	import {
		huifu_weichuang,
		like_weichuang,
		pinglun_children,
	} from "@/common/api/weichuang.js";
	export default {
		name: "pinglunChild",
		components: {
			progressBar,
		},
		props: {
			isDetail: {
				type: Boolean,
				default: false,
			},
			reply: {
				type: Boolean,
				default: true,
			},
			reply_one: {
				type: Boolean,
				default: true,
			},
			text: {
				type: String,
				default: "说的真好，给你点赞一个！！！",
			},
			promptSound: {
				type: Boolean,
				default: false,
			},
			id: {
				type: String,
				default: "",
			},
			item_id: {
				type: Object,
				default: () => {},
			},
			module_id: {
				type: String,
				default: "",
			},
			type: {
				type: Number,
				default: 0,
			},
			value: {
				type: Object,
				default: () => {
					return {};
				},
			},
			my_level_id: {
				type: Number,
				default: 0,
			}
		},
		data() {
			return {
				list: [],
			};
		},
		methods: {
			goHome() {
				uni.navigateTo({
					url: `/pages/home/home?user_id=${this.value.user.user_id}`,
				});
			},
			handZan(type) {
				console.log("rrrrrr", type, this.xinghe_id, this.discuss_id);

				// if (this.type == 14 || this.type == 15) {
				dianzan({
					id: this.id,
					type: this.type,
					comment_id: this.value.id,
					user_id: this.value.user_id,
				}).then((res) => {
					if (type == 0) {
						this.value.is_like = 1;
						this.value.like_count += 1;
					} else {
						this.value.is_like = 0;
						this.value.like_count -= 1;
					}
				});
				// } else {
				// 	like_weichuang({
				// 		id:this.id,
				// 		type:this.type,
				// 		comment_id:this.value.id,
				// 		user_id:this.value.user_id
				// 	}).then(res => {
				// 		if (type == 0) {
				// 			this.value.is_like = 1;
				// 			this.value.like_count += 1;
				// 		} else {
				// 			this.value.is_like = 0;
				// 			this.value.like_count -= 1;
				// 		}
				// 	})
				// }
			},
			expand() {
				console.log("ffffsdadwas");
				// pinglun_children({
				// 	id:this.value.id,
				// 	comment_id:this.value.id,
				// 	type:this.type,
				// 	page:this.page
				// }).then(res => {
				// 	this.list = res.data.list.data
				// 	console.log('ressss',res);
				// })
			},
			handReply(item) {
				console.log("vvvvvvvvv", this.value);
				this.$emit("reply", this.value);
			},
		},
	};
</script>
<style scoped lang="scss">
	.contents {
		margin-top: 27rpx;
		display: flex;
		margin-top: 32rpx;

		.avatar {
			width: 72rpx;
			height: 72rpx;

			.zanImg {
				border-radius: 36rpx;
				width: 72rpx;
				height: 72rpx;
			}
		}

		.avatarRight {
			width: 100%;

			padding-left: 16rpx;
			box-sizing: border-box;

			.nickTime {
				display: flex;
				justify-content: space-between;
				line-height: 36rpx;

				.nick {
					font-size: 22rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #888;
					display: flex;
					align-items: center;
					flex-wrap: wrap;

					.laoshi {
						font-size: 24rpx;
						background: #ffe9ce;
						color: #ffbb69;
						padding: 2rpx 12rpx;
						margin: 0 10rpx;
						box-sizing: border-box;
					}

					.daoshi {
						font-size: 24rpx;
						background: #efe0ff;
						color: #cda1ff;
						padding: 2rpx 12rpx;
						margin: 0 10rpx;
						box-sizing: border-box;
					}
				}

				.time {
					font-size: 24rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #888;
				}
			}

			.detail {
				line-height: 42rpx;
				font-size: 26rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #444444;
			}

			.detail_live {
				width: 492rpx;
				height: 132rpx;
				line-height: 42rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #444444;
				word-wrap: break-word;
				position: relative;

				.detail_view {
					width: 100%;
					height: 132rpx;
					background: linear-gradient(360deg, #FFFFFF 51%, rgba(255, 255, 255, 0) 100%);
					position: absolute;
					top: 0;
					left: 0;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #444444;
				}
			}

			.reply {
				width: 100%;
				padding: 10rpx 24rpx;
				box-sizing: border-box;
				font-size: 26rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				background: #eeeeee;
				color: #55b877;
				display: flex;
				margin-top: 16rpx;
			}

			.time_reply {
				width: 100%;
				display: flex;
				justify-content: space-between;
				margin-top: 16rpx;
				padding-bottom: 32rpx;
				border-bottom: 1rpx solid #eeeeee;
				margin-bottom: 32rpx;

				.time_reply_left {
					font-size: 24rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #888888;
					display: flex;
					margin-top: 16rpx;

					text {
						margin-left: 8rpx;
					}
				}

				.time_reply_right {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #888888;

					.zanImg1 {
						width: 25rpx;
						height: 27rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}
	}

	.item_right_sound {
		background: #f7f8fa;
		border-radius: 16rpx;
		padding: 32rpx;
		margin-top: 16rpx;
	}

	.child {
		width: 100%;
	}
</style>